using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Xml;
using System.Security.Principal; // here is the security namespace you need
You then call the getCurrent() method against WindowsIdentity, and then reference it's Name property like so:
this.nametext = WindowsIdentity.GetCurrent().Name;
That will return the name you need, so in my case it looks like 'DSclacy'
If you want to retrieve just the username without the domain portion and the '' delimeter, you can use a String.split() method in the same line of code like this:
this.nametext = WindowsIdentity.GetCurrent().Name.Split('')[1];
So in the example above that would simply return 'clacy'
christo